***********************************************************************
* HGREV replication for ISQ
***********************************************************************


* Peer reviewer allocations
***********************************************************************

* Data preparation
******************

  use "Reviewer selection", clear
  
  egen pid=group(R1 R2)
  xtset i pid
  
  replace review=100*review
  
  foreach x in major eu dacmodel{
   g rR1_`x'=(r_`x'==R1_`x')
   g rR2_`x'=(r_`x'==R2_`x')
   g R1R2_`x'=(R1_`x'==R2_`x')
   lab var rR1_`x' "r:`x'==R1:`x'"
   lab var rR2_`x' "r:`x'==R2:`x'"
   lab var R1R2_`x' "R1:`x'==R2:`x'"
  } 
  
  ** Major powers
  g majorp1=(rR1_major==1|rR2_major==1)
  g majorp2=(rR1_major==1&rR2_major==1)
  
  ** EU members 
  g rR1_eum=(r_eum==R1_eum)
  g rR2_eum=(r_eum==R2_eum)
  g eump1=max(rR1_eum, rR2_eum)
  g eump2=min(rR1_eum, rR2_eum)
  
  ** Contiguity
  g contig1=max(rR1_contig, rR2_contig)
  g contig2=min(rR1_contig, rR2_contig)
  
  ** Common language 
  g r_f=(r=="FRA"|r=="BEL"|r=="CHE"|r=="CAN"|r=="EU"|r=="LUX")
  g R1_f=(R1=="FRA"|R1=="BEL"|R1=="CHE"|R1=="CAN"|R1=="EU"|R1=="LUX")
  g R2_f=(R2=="FRA"|R2=="BEL"|R2=="CHE"|R2=="CAN"|R2=="EU"|R2=="LUX")
  g f1=(r_f==R1_f | r_f==R2_f)
  g f2=(r_f==R1_f & r_f==R2_f)
  lab var f1 "At least one common language"
  lab var f2 "Both common language"
  
  ** DAC model
  g model1=rR1_dacmodel==1|rR2_dacmodel==1
  g model2=rR1_dacmodel==1&rR2_dacmodel==1
  
  ** Familarity measures
  g before1=rR1_reviewedbefore>=1|rR2_reviewedbefore>=1
  g before2=rR1_reviewedbefore>=1&rR2_reviewedbefore>=1
  g beforepair=(rR1R2_reviewedbefore>0)
  
  ** UNGA voting
  egen unga=rowmean(rR1_un rR2_un)
  g ungarg=max(rR1_un, rR2_un)-min(rR1_un, rR2_un)
  
  ** LMEs
  g r_lme=0
  replace r_lme=1 if ((r=="GBR"|r=="USA"|r=="CAN"|r=="AUS"|r=="NZL") & year>=1985) | ((r=="DNK"|r=="SWE"|r=="NOR"|r=="FIN") & year>=1995)
  lab var r_lme "Reviewee: dynamic LME country - revised"
  g R1_lme=0
  replace R1_lme=1 if ((R1=="GBR"|R1=="USA"|R1=="CAN"|R1=="AUS"|R1=="NZL") & year>=1985) | ((R1=="DNK"|R1=="SWE"|R1=="NOR"|R1=="FIN") & year>=1995)
  lab var R1_lme "R1: dynamic LME country - revised"
  g R2_lme=0
  replace R2_lme=1 if ((R2=="GBR"|R2=="USA"|R2=="CAN"|R2=="AUS"|R2=="NZL") & year>=1985) | ((R2=="DNK"|R2=="SWE"|R2=="NOR"|R2=="FIN") & year>=1995)
  lab var R2_lme "R2: dynamic LME country - revised"
  
  g lme1=(r_lme==R1_lme | r_lme==R2_lme)
  lab var lme1 "At least one pair of similar VoCs"
  g lme2=(r_lme==R1_lme & r_lme==R2_lme)
  lab var lme2 "Both pairs similar VoCs"
  
  ** L/R ideology
  g rR1_aidmlr=abs(r_aidmlr-R1_aidmlr)
  g rR2_aidmlr=abs(r_aidmlr-R2_aidmlr)
  egen aidmlr=rowmean(rR1_aidmlr rR2_aidmlr)
  g aidmlrrg=max(rR1_aidmlr, rR2_aidmlr)-min(rR1_aidmlr, rR2_aidmlr)
  
  ** Donor size 
  g rR1_lnoda=ln(r_oda)/ln(R1_oda)
  g rR2_lnoda=ln(r_oda)/ln(R2_oda)
  g daidav=sqrt(rR1_lnoda*rR2_lnoda)
  g daidrg=max(rR1_lnoda, rR2_lnoda)/min(rR1_lnoda, rR2_lnoda)
  
  ** Democracy
  g rR1_vdem_delib=r_vdem_delib-R1_vdem_delib
  g rR2_vdem_delib=r_vdem_delib-R2_vdem_delib
  egen demoav=rowmean(rR1_vdem_delib rR2_vdem_delib)
  g demorg=max(rR1_vdem_delib, rR2_vdem_delib)-min(rR1_vdem_delib, rR2_vdem_delib)

  ** Geopolitics
  g arms1=(rR1_arms>0 | rR2_arms>0)
  g arms2=(rR1_arms>0 & rR2_arms>0)
  g atop1=(rR1_atop>0 | rR2_atop>0)
  g atop2=(rR1_atop>0 & rR2_atop>0)
  g dr1=(rR1_dr>0 | rR2_dr>0)
  g dr2=(rR2_dr>0 & rR2_dr>0)
  
  ** Reviewer characteristics
  g maxunemp=max(R1_wdi_unempy, R2_wdi_unempy)
  g mingrowth=min(R1_wdi_gdpcapgr, R2_wdi_gdpcapgr)
  g mingdppc=min(R1_wdi_gdpcapcon, R2_wdi_gdpcapcon)
  g maxcorr=max(R1_vdem_cor, R2_vdem_cor)
  
   ** Five largest in terms of GDP over time **
  g R1_majgdp=0
  replace R1_majgdp=1 if R1=="USA"|R1=="JPN"|R1=="DEU"|R1=="FRA"|R1=="GBR"
  replace R1_majgdp=0 if R1=="GBR" & year>=1980 & year<=1998
  replace R1_majgdp=1 if R1=="ITA" & year>=1980 & year<=1998
    
  g R2_majgdp=0
  replace R2_majgdp=1 if R2=="USA"|R2=="JPN"|R2=="DEU"|R2=="FRA"|R2=="GBR"
  replace R2_majgdp=0 if R2=="GBR" & year>=1980 & year<=1998
  replace R2_majgdp=1 if R2=="ITA" & year>=1980 & year<=1998

  g r_majgdp=0
  replace r_majgdp=1 if r=="USA"|r=="JPN"|r=="DEU"|r=="FRA"|r=="GBR"
  replace r_majgdp=0 if r=="GBR" & year>=1980 & year<=1998
  replace r_majgdp=1 if r=="ITA" & year>=1980 & year<=1998

  g rR1_majgdp=r_majgdp==R1_majgdp
  g rR2_majgdp=r_majgdp==R2_majgdp
  g majgdp1=max(rR1_majgdp, rR2_majgdp)
  g majgdp2=min(rR1_majgdp, rR2_majgdp)

  
  global X1 majorp1 majorp2 eump1 eump2 f1 f2 contig1 contig2 model1 model2 rR1R2_oneb beforepair before1 before2  
  global X2 unga* lme1 lme2 aidmlr* demo*  
  
  
* Descriptive statistics
************************  
  
** Table A1 **   
  qui estpost su review $X1 $X2 arms* atop* dr* daid* rR1_recip rR2_recip r_revavail R3 year  
  esttab ., cells("count mean(fmt(3)) sd(fmt(3)) min(fmt(3)) max(fmt(3))") noobs

    
* Main analysis
***************

  qui xtreg review $X1 if r!="EU", fe cl(i)  
  est store a1
  qui xtreg review $X2 if r!="EU", fe cl(i)
  est store a2
  qui xtreg review $X1 $X2 if r!="EU", fe cl(i) 
  est store a3 
  
** Table 1 **
  estout a*, starlevels(° .1  * .05 ** .01 *** 0.001) cells((b(star fmt(3)) se(par fmt(3)))) drop(_cons) stats(N r2_w, fmt(0 5))

  g major1=R1_major==1|R2_major==1
  g major2=R1_major==1&R2_major==1
  g eum1=(R1_eum==1 | R2_eum==1)
  g eum2=(R1_eum==1 & R2_eum==1)
  qui xtreg review major1 major2 eum1 eum2 model1 model2 rR1R2_onebf beforepair before1 before2 if r=="EU", fe cl(i)
  est store b1
  qui xtreg review major1 major2 eum1 eum2 model1 model2 rR1R2_onebf beforepair before1 before2 if r!="EU", fe cl(i)
  est store b2
 
** Table 2 **
  estout b*, starlevels(° .1  * .05 ** .01 *** 0.001) cells((b(star fmt(3)) se(par fmt(3)))) drop(_cons) stats(N r2_w, fmt(0 5))

    
* Robustness tests 
******************

  qui xtreg review majorp1 eump1 f1 contig1 model1 rR1R2_oneb beforepair before1 if r!="EU", fe cl(i)  
  est store c1
  qui xtreg review unga ungarg lme1 aidmlr aidmlrrg demoav demorg if r!="EU", fe cl(i)
  est store c2
  qui xtreg review majorp1 eump1 f1 contig1 model1 rR1R2_oneb beforepair before1 unga ungarg lme1 aidmlr aidmlrrg demoav demorg  if r!="EU", fe cl(i) 
  est store c3 
  
** Table A2 **
  estout c*, starlevels(° .1  * .05 ** .01 *** 0.001) cells((b(star fmt(3)) se(par fmt(3)))) drop(_cons) stats(N r2_w, fmt(0 5))

  
  qui xtreg review majorp2 eump2 f2 contig2 model2 rR1R2_oneb beforepair before2 if r!="EU", fe cl(i)  
  est store d1
  qui xtreg review unga ungarg lme2 aidmlr aidmlrrg demoav demorg if r!="EU", fe cl(i)
  est store d2
  qui xtreg review majorp2 eump2 f2 contig2 model2 rR1R2_oneb beforepair before2 unga ungarg lme2 aidmlr aidmlrrg demoav demorg  if r!="EU", fe cl(i) 
  est store d3 

** Table A3 **
  estout d*, starlevels(° .1  * .05 ** .01 *** 0.001) cells((b(star fmt(3)) se(par fmt(3)))) drop(_cons) stats(N r2_w, fmt(0 5))

  
  qui xtreg review arms* atop* dr* if r!="EU", fe cl(i)  
  est store e1
  qui xtreg review arms* atop* dr* $X2 if r!="EU", fe cl(i)
  est store e2
  qui xtreg review arms* atop* dr* $X2 $X1 if r!="EU", fe cl(i) 
  est store e3 
  
** Table A4 **
  estout e*, starlevels(° .1  * .05 ** .01 *** 0.001) cells((b(star fmt(3)) se(par fmt(3)))) drop(_cons) stats(N r2_w, fmt(0 5))

  
  global X3 majgdp1 majgdp2 eump* f1 f2 contig* model1 model2 rR1R2_onebf beforep before1 before2 
  qui xtreg review $X3 if r!="EU", fe cl(i)  
  est store f1
  qui xtreg review $X2 if r!="EU", fe cl(i)
  est store f2
  qui xtreg review $X3 $X2 if r!="EU", fe cl(i) 
  est store f3 
  
** Table A5 **
  estout f*, starlevels(° .1  * .05 ** .01 *** 0.001) cells((b(star fmt(3)) se(par fmt(3)))) drop(_cons) stats(N r2_w, fmt(0 5))
 

  global X4 daid* eump* f1 f2 contig* model1 model2 rR1R2_onebf beforep before1 before2 
  qui xtreg review $X4 if r!="EU", fe cl(i)  
  est store g1
  qui xtreg review $X2 if r!="EU", fe cl(i)
  est store g2
  qui xtreg review $X4 $X2 if r!="EU", fe cl(i) 
  est store g3 
  
** Table A6 **
  estout g*, starlevels(° .1  * .05 ** .01 *** 0.001) cells((b(star fmt(3)) se(par fmt(3)))) drop(_cons) stats(N r2_w, fmt(0 5))
 
 
  qui xtreg review $X1 r_rev R3 i.year if r!="EU", re cl(i)  
  est store h1
  qui xtreg review $X2 r_rev R3 i.year if r!="EU", re cl(i)
  est store h2
  qui xtreg review $X1 $X2 r_rev R3 i.year if r!="EU", re cl(i) 
  est store h3 
  
** Table A7 **
  estout h*, starlevels(° .1  * .05 ** .01 *** 0.001) cells((b(star fmt(3)) se(par fmt(3)))) drop(_cons *year*) stats(N r2_w, fmt(0 5))

  
  qui xtreg review $X1 if r!="EU", fe cl(year)  
  est store i1
  qui xtreg review $X2 if r!="EU", fe cl(year)
  est store i2
  qui xtreg review $X1 $X2 if r!="EU", fe cl(year) 
  est store i3 
  
** Table A8 **
  estout i*, starlevels(° .1  * .05 ** .01 *** 0.001) cells((b(star fmt(3)) se(par fmt(3)))) drop(_cons) stats(N r2_w, fmt(0 5))

  
  ** Reviewer characteristics
   
  qui xtreg review maxunemp mingr maxcorr $X1 if r!="EU", fe cl(i)  
  est store j1
  qui xtreg review maxunemp mingr maxcorr $X2 if r!="EU", fe cl(i)
  est store j2
  qui xtreg review maxunemp mingr maxcorr $X1 $X2 if r!="EU", fe cl(i) 
  est store j3 
  
** Table A9 **
  estout j*, starlevels(° .1  * .05 ** .01 *** 0.001) cells((b(star fmt(3)) se(par fmt(3)))) drop(_cons) stats(N r2_w, fmt(0 5))
 
 
  qui xtreg review rR1_recip rR2_recip if r!="EU", fe cl(i)  
  est store k1
  qui xtreg review rR1_recip rR2_recip $X1 if r!="EU", fe cl(i)
  est store k2
  qui xtreg review rR1_recip rR2_recip $X1 $X2 if r!="EU", fe cl(i) 
  est store k3 
  
  ** Table A10 **
  estout k*, starlevels(° .1  * .05 ** .01 *** 0.001) cells((b(star fmt(3)) se(par fmt(3)))) drop(_cons) stats(N r2_w, fmt(0 5))
 
 
 


* Recipient-country allocations
*********************************************************************** 
